<?php

//充值订单
//
namespace app\ausadmin\controller;
use app\ausadmin\controller\Common;
use think\Request;
use think\Db;
use think\File;
use think\Session;
use think\Cookie;
use Godok\Org\FileManager;
class Rechargeorder extends Common
{

	public function index(){
		$b = 'user';//定义用户表	
		$where ='a.is_delete = 1 AND a.pay_status = 1 AND  a.oid = '.session('oid');//.Session::get('oid')获取
		$pages= 20;//每页显示记录数
		//以下代码是判断是否改变每页显示记录数,把提交的数写入cookie,这样我们点击下一页的数字就是正常的了,否则分页默认又会从10开始
		/*if(input('pages')!=''){
			$pages = input('pages');
			
			if(cookie('pages')){
				Cookie::delete('pages');
			}
			Cookie::set('pages',$pages,600);
		}
		//以下代码是判断用户是否是自定义每页显示记录数,防止点击下一页的时候又从默认10开始
		if(cookie('pages')){
			$pages = cookie('pages');
		}*/
		//获取是否按支付状态查询
		/*if(input('pay_status')!=''){
			$status = input('pay_status');
			$where .= ' AND a.pay_status = '.input('pay_status');
			//把支付状态的数据写入cookie;
			if(cookie('paystatus')){
				Cookie::delete('paystatus');
			}
			Cookie::set('paystatus',$status,600);
		}
		if(cookie('paystatus')){
			$where .= ' AND a.pay_status = '.cookie('paystatus');
		}
		*/
		//获取是否是查询订单号
		if(input('order_no')!=''){
			$where .= ' AND a.order_no = '.input('order_no');
		}
		//获取是否查询到用户名
		if(input('name')!=''){
			if(cookie('cz_name')){
				Cookie::delete('cz_name');
			}
			Cookie::set('cz_name',input('name'),30);
			$where .= ' AND b.name LIKE '."'%".cookie('cz_name')."%' ";
		}
		 if(cookie('cz_name')){
		 	$where .= ' AND b.name LIKE '."'%".cookie('cz_name')."%' ";
		 }

		//以下代码是判断是否是按支付状态查询
		
		$list=Db::name('rechargeorder')
			->alias('a')
			->join("$b b",'a.oid = b.oid and a.uid = b.id')
			->field('a.id,a.order_no,a.trade_no,a.balance,a.deposit,a.refunddeposit,a.pay_mode,a.pay_status,a.payment_date,a.create_time,a.is_delete,b.name')
			->where($where)
			->paginate($pages);
		$this->assign('list',$list);

		return $this->fetch();

	}





}